#include <bits/stdc++.h>

using namespace std;

int n, m, l, v;

struct Car{
    int d;
    int v;
    int a;
};

int how_many_car(vector<Car> & c, vector<int> & p, vector<bool> & f){
    int cnt = 0;
    for (int i = 0; i < c.size(); ++i){
        //(v * v - c[i].v * c[i].v) / (2 * a[i]) 
        double cd = (double)(v * v - c[i].v * c[i].v) / (double)(2 * c[i].a);
        for (int j = 0; j < p.size(); ++j){    
            if (c[i].a < 0){
                if (p[i] >= cd){
                    cnt++;
                    break;
                }
            }
            else{
                if (p[i] <= cd){
                    cnt++;
                    break;
                }
            }
        }
    }
    return cnt;
}

bool check(int mid, vector<Car> & c, vector<int> & p, vector<bool> & f){
    int cnt = 0;
    for (int i = 0; i < f.size(); ++i){
        if (f[i]){
            cnt++;
        }
    }
    return cnt <= mid;
}

int how_many_detected(vector<Car> & c, vector<int> & p, vector<bool> & f){
    int l = 0, r = p.size();
    while (l <= r){
        int mid = (l + r) / 2;
        if (check(mid, c, p, f)){
            l = mid - 1;
        }
        else{
            r = mid + 1;
        }
    }
    return l - 1;
}

int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);

    int t;
    cin >> t;

    while (t--){
        cin >> n >> m >> l >> v;

        vector<Car> c;
        for (int i = 0; i < n; ++i){
            int d, v, a;
            cin >> d >> v >> a;
            c.push_back({d, v, a});
        }

        vector<int> p;
        for (int i = 0; i < m; ++i){
            int x;
            cin >> x;
            p.push_back(x);
        }
        vector<bool> f(m + 1, false);
        cout << how_many_car(c, p, f) << ' ' << how_many_detected(c, p, f) << endl;
    }    
    return 0;
}